package edu.ccut.saturn.basevalidate.prvalidate;

import edu.ccut.saturn.component.DefaultSaturnValidate;
import edu.ccut.saturn.component.ValidateResult;

public class IsPhoneValidate extends DefaultSaturnValidate {

//	private static final String phoneRegExpr = "[1-9]{1}[0-9]{5,8}";

//	private static final String phoneWithArea = "[0][1-9]{2,3}-[0-9]{5,10}";

	private static final String landlineRegExpr = "(^(0\\d{2})-(\\d{8})$)|(^(0\\d{3})-(\\d{7})$)|(^(0\\d{2})-(\\d{7})$)|(^(0\\d{3})-(\\d{8})$)";

	public void doValidate(Object value, Object[] args, ValidateResult result) {
		if (!(value.toString()).matches(landlineRegExpr)) {
			sendError(_ERROR_, value, result);
		}
	}
}
